//
//  NewsDetailController.m
//  Notice
//
//  Created by CPX on 2018/8/21.
//  Copyright © 2018年 CPX. All rights reserved.
//

#import "NewsDetailController.h"
#import "NoticeDetailCell.h"
#import "NoticeModel.h"

/**
 系统通知详情页
 @author yzl
 */
@interface NewsDetailController ()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) UITableView *table;

//@property (nonatomic,strong) NSArray *data;

@end

@implementation NewsDetailController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self initUI];
    [self loadData];
}



- (void)initUI{
    [self initNavigation];
    
    self.table = [[UITableView alloc] initWithFrame:CGRectMake(0, NavHeight, kScreenWidth, kScreenHeight - NavHeight) style:UITableViewStylePlain];
    self.table.delegate = self;
    self.table.dataSource = self;
    self.table.rowHeight = UITableViewAutomaticDimension;
    self.table.estimatedRowHeight = 80;
    self.table.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.view.backgroundColor = UIColorHex(#f4f4f4);
    self.table.backgroundColor = UIColorHex(#f4f4f4);;
    //    self.table.tableHeaderView = self.headerView;
    [self.view addSubview:self.table];
}


- (void)initNavigation{
    [self.navigationController setNavigationBarHidden:YES];
    
    [self initLeftBackNaviButton];
    //    [self.myNavigationBar.backButton setImage:nil forState:UIControlStateNormal];
    [self.myNavigationBar.backButton setTitle:TLString(@"Notice") forState:UIControlStateNormal];
}

- (void)loadData{
//    self.notice = [NoticeModel yy_modelWithJSON:self.data];
//    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
//    //设定时间格式,这里可以设置成自己需要的格式
//    [dateFormatter setDateFormat:@"dd/MM HH:mm"];
//    //用[NSDate date]可以获取系统当前时间
//    NSString *currentDateStr = [dateFormatter stringFromDate:[NSDate date]];
//    self.notice.dateStr = currentDateStr;
//    [self.table reloadData];
    if (self.data) {
        self.notice = [NoticeModel yy_modelWithJSON:self.data];
        NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
        //设定时间格式,这里可以设置成自己需要的格式
        [dateFormatter setDateFormat:@"dd/MM HH:mm"];
        //用[NSDate date]可以获取系统当前时间
        NSString *currentDateStr = [dateFormatter stringFromDate:[NSDate date]];
        self.notice.createDateFormatStr = currentDateStr;
    }
    self.notice.status = 1;
    [self.table reloadData];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NoticeDetailCell *cell = [NoticeDetailCell cellWithTable:tableView];
//    cell.notice = self.list[indexPath.row];
    cell.notice = self.notice;
    return cell;
}

@end
